<?php
/* @var $this ShiftChangeController */
/* @var $model ShiftChange */

$this->menu=array(
	//array('label'=>'List ShiftChange', 'url'=>array('index')),
	array('label'=>'Back to Management', 'url'=>array('change_management')),
);

$cs = Yii::app()->getClientScript();  
$cs->registerScript(
  'radio-type-handler',
  '
	function radioToggle(){
		var r1selected= document.getElementById("choice_0").checked;
		var r2selected= document.getElementById("choice_1").checked;
		
		//alert("r1selected= " + r1selected);
		//alert("r2selected= " + r2selected);
		
		if (r1selected) {
			document.getElementById("ShiftChange_requested_shift").style.visibility = "visible";
			document.getElementById("ShiftChange_requested_qshift").style.visibility = "visible";
			document.getElementById("ShiftChange_target_user").style.visibility = "hidden";
			document.getElementById("txt_target_shift").style.visibility = "hidden";
			document.getElementById("txt_target_qshift").style.visibility = "hidden";
		} else if (r2selected) {
			document.getElementById("ShiftChange_requested_shift").style.visibility = "hidden";
			document.getElementById("ShiftChange_requested_qshift").style.visibility = "hidden";
			document.getElementById("ShiftChange_target_user").style.visibility = "visible";
			document.getElementById("txt_target_shift").style.visibility = "visible";
			document.getElementById("txt_target_qshift").style.visibility = "visible";
		}
	}
	
	function setRequestedShiftQshift(shift, qshift){
	
		//alert("shift= " + shift + " qshift= " +qshift);

		//VOY ACA, EL SELECTED INDEX NO ES EL VALUE, HAY QUE SELECCIONAR EL VALUE... 
		//USAR ITERACION DE LOS INDEXES PARA COMPARAR EL VALUE Y EL INDEX
		
		var shiftOptions = document.getElementById("ShiftChange_requested_shift").options;
		var qshiftOptions = document.getElementById("ShiftChange_requested_qshift").options;
		var shiftIndexPos = 0;
		var qshiftIndexPos = 0;
		
		for (var i=0; i < shiftOptions.length ; i++) {
			if (shiftOptions[i].value == shift) {
				shiftIndexPos = i;	
			}	//alert("shift i = " + i);
		}		
		
		for (var j=0; j < qshiftOptions.length ; j++) {
			if (qshiftOptions[j].value == qshift){
				qshiftIndexPos = j;		
			}	//alert("qshift j = " + j);				
		}
		
		document.getElementById("ShiftChange_requested_shift").selectedIndex = shiftIndexPos;
		document.getElementById("ShiftChange_requested_qshift").selectedIndex = qshiftIndexPos;
	
	}
	
	function cleanDropdown(dropdownId) {
	
		document.getElementById(dropdownId).selectedIndex = 0;
	}
  ',
  CClientScript::POS_END
);
?>
<center>

<h2>Creating Shift Change</h2>

<?php echo $this->renderPartial('_ajaxRosterCreate_form', array('model'=>$model)); ?>